package descentFly.app.tools
{
	import UIFree.ObjectEvent;
	import UIFree.controls.uif_label;
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	
	import descentFly.app.df_component;
	import descentFly.app.df_label;
	import descentFly.app.df_panel;
	import descentFly.app.df_progressBar;
	import descentFly.chips.df_chip;
	import descentFly.df_space;
	
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	public class df_statusPanel extends df_chipTool {
		public function df_statusPanel(parent:uif_component, aheight:int=0) {
			super(parent, 100, aheight);
		}
		
		override protected function setMyChip(a_chip: df_chip):void {
			if (myChip) myChip.removeEventListener(df_chip.LIVECHANGE, doChangeLive);
			super.setMyChip(a_chip);
			if (myChip) {
				myChip.addEventListener(df_chip.LIVECHANGE, doChangeLive);
				refreshLive();
			}
		}
		
		protected function refreshLive(): void {
			liveValue = myChip.live/myChip.maxLive;
		}
		
		public function doChangeLive(e: Event): void {
			refreshLive();
		}
		
		protected function get liveValue(): Number {
			return pb.percent;
		}
		
		protected function set liveValue(a_percent: Number): void {
			pb.percent = a_percent;
			label.text = 'Жизнь: ' + Math.round(a_percent * 100);
		}
	}
}